package com.guigu.www.erp.dehao.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.guigu.www.erp.common.dao.SPayDetailsMapper;
import com.guigu.www.erp.common.dao.SPayMapper;
import com.guigu.www.erp.common.pojo.*;
import com.guigu.www.erp.dehao.dao.MApplyMapper;
import com.guigu.www.erp.dehao.dao.MManufactureMapper;
import com.guigu.www.erp.dehao.dao.MProcedureMapper;
import com.guigu.www.erp.dehao.dao.MProcedureModuleMapper;
import com.guigu.www.erp.dehao.service.DHMManufactureService;
import com.guigu.www.erp.dengtao.dao.MDesignProcedureDetailsMapper;
import com.guigu.www.erp.dengtao.dao.MDesignProcedureMapper;
import com.guigu.www.erp.dengtao.dao.MDesignProcedureModuleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class DHMManufactureServiceImpl implements DHMManufactureService {

    @Autowired
    private MManufactureMapper mManufactureMapper;

    @Autowired
    private MApplyMapper mApplyMapper;

    @Autowired
    private MDesignProcedureMapper mDesignProcedureMapper;

    @Autowired
    private MDesignProcedureDetailsMapper detailsMapper;

    @Autowired
    private MDesignProcedureModuleMapper moduleMapper;

    @Autowired
    private MProcedureMapper mProcedureMapper;

    @Autowired
    private MProcedureModuleMapper mProcedureModuleMapper;

    @Autowired
    private SPayMapper sPayMapper;

    @Autowired
    private SPayDetailsMapper sPayDetailsMapper;


    @Override
    public void insertSelective(MManufacture mManufacture) {
        mManufactureMapper.insertSelective(mManufacture);
    }

    @Override
    public MManufacture selectByPrimaryKey(Integer id) {
        return mManufactureMapper.selectByPrimaryKey(id);
    }

    @Override
    public void updateByPrimaryKeySelective(MManufacture mManufacture) {
        mManufactureMapper.updateByPrimaryKeySelective(mManufacture);
    }

    @Override
    public PageVo<MApply> queryByCheckMApply1(Integer pageNum,Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<MApply> mApplies = mApplyMapper.queryByCheckMApply1();
        PageInfo<MApply> info = new PageInfo<>(mApplies);
        return new PageVo<>(info.getTotal(),info.getList());
    }

    @Override
    public Integer numberManufactureTagGroup0() {
        return mApplyMapper.numberManufactureTagGroup0();
    }

    @Override
    public Integer numberManufactureTag0() {
        return mApplyMapper.numberManufactureTag0();
    }

    @Override
    public MDesignProcedure DHQueryByProductId(String productId) {
        return mDesignProcedureMapper.DHQueryByProductId(productId);
    }

    @Override
    public String queryMaxManufacture() {
        return mManufactureMapper.queryMaxManufacture();
    }

    @Override
    public List<MDesignProcedureDetails> queryByParentIdProcedureDetails(String parentId) {
        return detailsMapper.selectcx(parentId);
    }

    @Override
    public List<MDesignProcedureModule> queryByParentIdModule(Integer parentId) {
        return moduleMapper.queryByParentIdModule(parentId);
    }

    @Override
    public void insertModule(MProcedureModule mProcedureModule) {
        mProcedureModuleMapper.insertSelective(mProcedureModule);
    }

    @Override
    public void insertProcedure(MProcedure mProcedure) {
        mProcedureMapper.insertSelective(mProcedure);
    }

    @Override
    public void updateMApplyTag(MApply mApply) {
        mApplyMapper.updateByPrimaryKeySelective(mApply);
    }

    @Override
    public PageVo<MManufacture> queryAllByCheckTag(Integer pageNum,Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<MManufacture> mManufactures = mManufactureMapper.queryAllByCheckTag();
        PageInfo<MManufacture> info = new PageInfo<>(mManufactures);
        return new PageVo<>(info.getTotal(),info.getList());
    }

    @Override
    public List<MProcedureModule> queryByParentIdPM(Integer parentId) {
        return mProcedureModuleMapper.queryByParentIdPM(parentId);
    }

    @Override
    public PageVo<MManufacture> queryAllMManufacture(Integer pageNum, Integer pageSize, String productName, String startTime, String endTime) {
        PageHelper.startPage(pageNum,pageSize);
        List<MManufacture> mManufactures = mManufactureMapper.queryAllMManufacture
                ("%"+productName+"%", startTime, endTime);
        PageInfo<MManufacture> info = new PageInfo<>(mManufactures);
        return new PageVo<>(info.getTotal(),info.getList());
    }

    @Override
    public Integer queryByCheckTag0() {
        return mManufactureMapper.queryByCheckTag0();
    }

    @Override
    public Integer queryByCheckTag1() {
        return mManufactureMapper.queryByCheckTag1();
    }

    @Override
    public Integer queryByCheckTag2() {
        return mManufactureMapper.queryByCheckTag2();
    }

    @Override
    public void insertSPay(SPay sPay) {
        sPayMapper.insertSelective(sPay);
    }

    @Override
    public void insertSPayDetails(SPayDetails sPayDetails) {
        sPayDetailsMapper.insertSelective(sPayDetails);
    }

    @Override
    public String queryMaxSPay() {
        return sPayMapper.getMaxPayId();
    }

    @Override
    public Integer queryModuleAmount(String arr) {
        return mManufactureMapper.queryModuleAmount(arr);
    }

    @Override
    public Integer queryModuleSubtotal(String arr) {
        return mManufactureMapper.queryModuleSubtotal(arr);
    }

    @Override
    public List<MProcedureModule> queryArrModuleDetails(String arr) {
        return mProcedureModuleMapper.queryArrModuleDetails(arr);
    }

    @Override
    public void updateMProcedureById(MProcedure mProcedure) {
        mProcedureMapper.updateByPrimaryKeySelective(mProcedure);
    }


}
